#!/bin/bash

vmdetail=$(vboxmanage showvminfo $1 --machinereadable 2> /dev/null)
if [ "$?" -eq 0 ]; then
	while [ "$answer" != "yes" ] && [ "$answer" != "no" ]; do
		echo -n "Are you sure you want to delete $1 (yes/no)? "
		read answer
	done;
	if [ "$answer" == "yes" ]; then
		echo "Deleting $1"
		vboxmanage unregistervm $1 --delete
	fi
else
	echo "VM '$1' does not exist"
fi
